package datahandling;

import java.util.*;

public class TxtFile{
	private final String path;
	private String fileName;
	private int label_pos;
	private List<Integer> rowList;
	private int rowNum ;

	public TxtFile(String path) {

		this.path = path;
		//调用分析器得到文件名和标签位
		String[] result = Analyzer.getFileInfo(path);
		this.label_pos = Integer.valueOf(result[0]);
		this.fileName = result[1];
		//
		//调用分析器得到每行列数和文件数据维度
		this.rowList = Analyzer.readLines(this.path,this.fileName,this.label_pos);
		this.rowNum = Analyzer.getDimension(rowList);
		//输出文件信息
		outInfo();
	}
	
	public void outInfo(){
      for(int i = 0;i <= rowList.size()-1 ;i++){
      	int offset = rowList.get(i) - rowNum;
      	if( offset != 0)
      		System.out.println("\t the row num of " + i + " line different from others,offset is: " + offset );
      }
      int dimension = rowNum - 1;
      System.out.println("\t the dimension of " + fileName + " is:" + dimension);
	}
}
